package org.linlinjava.litemall.admin.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.linlinjava.litemall.admin.beans.annotation.LogAnno;
import org.linlinjava.litemall.admin.service.AdminLumiereFormulaTypeService;
import org.linlinjava.litemall.core.util.ResponseUtil;
import org.linlinjava.litemall.db.domain.LumiereFormulaType;
import org.springframework.web.bind.annotation.*;

@Api(tags = "配方类型管理API")
@RestController
@RequestMapping("admin/formulaType")
@RequiredArgsConstructor
public class AdminLumiereFormulaTypeController {

    private final AdminLumiereFormulaTypeService adminLumiereFormulaTypeService;
    @ApiOperation("配方类型管理-查询配方类型列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "limit",value = "数量"),
            @ApiImplicitParam(name = "page",value = "当前页"),
            @ApiImplicitParam(name = "formulaName",value = "配方类型名称")
    })
    @LogAnno
    @GetMapping("/list")
    public ResponseUtil.Response list(LumiereFormulaType lumiereFormulaType,
                                      @RequestParam("limit")Integer limit,
                                      @RequestParam("page")Integer page) {
        return adminLumiereFormulaTypeService.listLumiereFormulaType(lumiereFormulaType,page,limit);
    }

    @ApiOperation("配方类型管理-新增配方类型")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "formulaTypeName",value = "配方类型名称"),
            @ApiImplicitParam(name = "typeColour",value = "类型颜色"),
            @ApiImplicitParam(name = "number",value = "序号"),
            @ApiImplicitParam(name = "remark",value = "备注"),
    })
    @LogAnno
    @PostMapping("/add")
    public ResponseUtil.Response add(LumiereFormulaType lumiereFormulaType)  {
        return adminLumiereFormulaTypeService.addLumiereFormulaType(lumiereFormulaType);
    }

    @ApiOperation("配方类型管理-编辑配方类型")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "formulaTypeName",value = "配方类型名称"),
            @ApiImplicitParam(name = "typeColour",value = "类型颜色"),
            @ApiImplicitParam(name = "number",value = "序号"),
            @ApiImplicitParam(name = "remark",value = "备注"),
    })
    @LogAnno
    @PutMapping ("/update")
    public ResponseUtil.Response update(LumiereFormulaType lumiereFormulaType)  {
        return adminLumiereFormulaTypeService.updateLumiereFormulaType(lumiereFormulaType);
    }

    @ApiOperation("配方类型管理-删除配方类型")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id",value = "id"),
    })
    @LogAnno
    @DeleteMapping("/delete")
    public ResponseUtil.Response delete(Integer id)  {
        return adminLumiereFormulaTypeService.deleteLumiereFormulaType(id);
    }


}
